<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>prefersLightColorScheme</title>
</head>
<body>
    <p>当前是否使用明亮主题: <span id="text"></span></p>
    <script>
      const prefersLightColorScheme = () =>
        window &&
        window.matchMedia &&
        window.matchMedia('(prefers-color-scheme: light)').matches;
      document.querySelector('#text').textContent = prefersLightColorScheme()
        ? '是'
        : '否';
    </script>
</body>
</html>